<template>
  <el-popconfirm
    :title="title"
    :placement="placement"
    :width="width"
    :show-icon="showIcon"
    @confirm="handleConfirm"
    @cancel="handleCancel"
  >
    <template #reference>
      <slot></slot>
    </template>
  </el-popconfirm>
</template>

<script setup>
import { ElPopconfirm ,ElButton} from "element-plus";

// 定义组件属性
const props = defineProps({
  title: {
    type: String,
    default: "Are you sure?",
  },
  placement: {
    type: String,
    default: "top",
  },
  width: {
    type: Number,
    default: 300,
  },
  showIcon: {
    type: Boolean,
    default: true,
  },
});

// 定义事件发射器
const emit = defineEmits(["confirm", "cancel"]);

// 处理确认事件
const handleConfirm = () => {
  emit("confirm");
};

// 处理取消事件
const handleCancel = () => {
  emit("cancel");
};
</script>
